package cn.hamster3.mc.plugin.core.common.thread;

import org.jetbrains.annotations.NotNull;

import java.util.concurrent.ThreadFactory;

public class NamedThreadFactory implements ThreadFactory {
    private final String name;
    private int threadID;

    public NamedThreadFactory(String name) {
        this.name = name;
        threadID = 0;
    }

    @Override
    public Thread newThread(@NotNull Runnable runnable) {
        threadID++;
        return new Thread(runnable, name + "#" + threadID);
    }
}
